app.service('goodsDetailEvaluateService',['$q','utilService',function($q,utilService){
    var _this_=this;
    //查询商品id
    _this_.findById = function($scope){
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'goods/other/'+ $scope.id
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错！");
        });
        return deferred.promise;
    }

    //查询评价列表
    _this_.findAll=function($scope){
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'user/evaluate/',
            params:{'goodsId':$scope.id,start:$scope.page*$scope.length,draw:1,length:$scope.length}
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错！");
        });
        return deferred.promise;
    }

    //查询评价总和
    _this_.findEvaluateCount=function($scope){
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'user/evaluate/count/'+$scope.id,
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错！");
        });
        return deferred.promise;
    }

}])